﻿@{
    DtoCurrentUser currentUser = ViewData["CurrentUser"] as DtoCurrentUser ?? new DtoCurrentUser();
    string menuIndex = ViewData["MenuIndex"]?.ToString()?.ToLower().Trim() ?? string.Empty;
    bool isHome = ViewBag.IsHome ?? false;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>管理系统 - @ViewData["Title"]</title>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
    @await RenderSectionAsync("Styles", required: false)
</head>
<body>
    <!-- 顶部导航栏 -->
    <header class="header">
        <div class="system-info">
            <div class="logo">
                <i class="tas tas-stack"></i>
            </div>
            <h1 class="system-name">欣欣志盛后台管理系统</h1>
        </div>
        <div class="user-info">
            <div class="user-notification" title="您有3条未读消息">
                <i class="tas tas-bell"></i>
                <span class="notification-badge">3</span>
            </div>
            <div class="user-dropdown dropdown">
                <a class="dropdown-toggle" href="javascript:void(0);" data-bs-toggle="dropdown" aria-expanded="false">
                    <img src="@currentUser?.Avatar" class="user-avatar" alt="用户头像">
                    <span class="user-name">@currentUser?.Name</span>
                </a>
                <ul class="dropdown-menu dropdown-menu-end">
                    <li>
                        <a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#changePasswordModal">
                            <i class="bi bi-key me-2"></i>修改密码
                        </a>
                    </li>
                    <li><hr class="dropdown-divider"></li>
                    <li>
                        <a class="dropdown-item text-danger" href="#" data-bs-toggle="modal" data-bs-target="#logoutModal">
                            <i class="bi bi-box-arrow-right me-2"></i>退出系统
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </header>

    <!-- 主体内容区域 -->
    <div class="main-container">
        <!-- 左侧菜单 -->
        <aside class="sidebar">
            <nav class="menu-items">
                <a href="/" class="menu-item @((string.IsNullOrEmpty(menuIndex) || menuIndex == "/home/index") ? "active" : "")">
                    <i class="tas tas-home"></i>
                    <span class="menu-text">控制台</span>
                </a>
                <a href="/user/index" class="menu-item @(menuIndex == "/user/index" ? "active" : "")">
                    <i class="tas tas-users"></i>
                    <span class="menu-text">用户管理</span>
                </a>
                <a href="/article/index" class="menu-item @(menuIndex == "/article/index" ? "active" : "")">
                    <i class="tas tas-users"></i>
                    <span class="menu-text">文章管理</span>
                </a>
                <!-- 系统设置菜单（有二级菜单） -->
                <div class="menu-item @((menuIndex == "/setting/index" || menuIndex == "/setting/permission") ? "expanded" : "")">
                    <i class="tas tas-cog"></i>
                    <span class="menu-text">系统设置</span>
                    <i class="tas tas-arrow"></i>
                </div>
                <div class="submenu">
                    <a href="/setting/index" class="submenu-item @(menuIndex == "/setting/index" ? "active" : "")">基本设置</a>
                    <a href="/setting/permission" class="submenu-item @(menuIndex == "/setting/permission" ? "active" : "")">权限设置</a>
                </div>
            </nav>
        </aside>

        <!-- 右侧内容区域 -->
        <main class="@(isHome ? "homecontent" : "content")">
            @RenderBody()
        </main>
    </div>

    <!-- 修改密码模态框 -->
    <div class="modal fade" id="changePasswordModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><i class="bi bi-key me-2"></i>修改密码</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="mb-3">
                        <label for="changePasswordOld" class="form-label">原密码</label>
                        <input type="password" class="form-control" id="changePasswordOld" placeholder="请输入原密码">
                    </div>
                    <div class="mb-3">
                        <label for="changePasswordNew" class="form-label">新密码</label>
                        <input type="password" class="form-control" id="changePasswordNew" placeholder="请输入新密码">
                    </div>
                    <div class="mb-3">
                        <label for="changePasswordConfirm" class="form-label">确认新密码</label>
                        <input type="password" class="form-control" id="changePasswordConfirm" placeholder="请再次输入新密码">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="btnConfirmChangePWD">确认修改</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 退出系统确认模态框 -->
    <div class="modal fade" id="logoutModal" tabindex="-1" aria-hidden="true" data-bs-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><i class="bi bi-box-arrow-right me-2"></i>退出系统</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <p class="lead">确定要退出系统吗？</p>
                    <p class="text-muted">退出后需要重新登录才能访问系统。</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-danger" id="btnConfirmLogout">确认退出</button>
                </div>
            </div>
        </div>
    </div>

    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>